﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:attached="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Base.Controls.Attached"
                    xmlns:ribbonHelper="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Base.Controls.Ribbon"
                    xmlns:conv="clr-namespace:Tum.PDE.ToolFramework.Modeling.Visualization.Base.Converters"
                    xmlns:fluent="clr-namespace:Fluent;assembly=Fluent">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Tum.PDE.ToolFramework.Modeling.Visualization.Base;component/Themes/Default/LinkItemsStyle.xaml"/>
        <ResourceDictionary Source="/Tum.PDE.ToolFramework.Modeling.Visualization.Base;component/Themes/Default/NoMouseOverButtonStyle.xaml"/>
        <ResourceDictionary Source="/Tum.PDE.ToolFramework.Modeling.Visualization.Base;component/Themes/Default/RibbonInGalleryItemStyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <conv:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

    <ControlTemplate x:Key="RibbonBackstageRecentItemsTemplate">
        <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
            <StackPanel Margin="15, 10, 0, 0" Orientation="Vertical" Width="500" HorizontalAlignment="Left" >

                <!-- Recent Documents TextBlock -->
                <Grid Margin="0,0,10,0">
                    <TextBlock Margin="0,5" TextWrapping="Wrap" Text="Recent Documents" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Foreground="#FF5E5E5E"/>
                    <Path Data="M0,0L1,0" Fill="{x:Null}" Height="1" Margin="0" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" Stroke="{DynamicResource RibbonTopBorderBrush}" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" VerticalAlignment="Bottom" StrokeDashArray="2 2"/>
                </Grid>

                <!-- ListBox -->
                <ListBox x:Name="lstBoxMRUEntries" Width="500" Margin="0, 10, 0, 0" BorderThickness="0" BorderBrush="Transparent" DataContext="{Binding Path=MRUFilesViewModel, Mode=OneWay}"
                                            ItemsSource="{Binding Path=MRUFileEntries, Mode=OneWay}"
                                            SelectedItem="{Binding Path=SelectedMRUFileEntry, Mode=TwoWay}">

                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="48"/>
                                    <ColumnDefinition Width="370"/>
                                    <ColumnDefinition Width="22"/>
                                    <ColumnDefinition Width="22"/>
                                </Grid.ColumnDefinitions>

                                <Image Source="/Tum.PDE.ToolFramework.Images;component/Ribbon/RecentItem-32.png" Width="32" Height="32" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                <StackPanel Orientation="Vertical" Grid.Column="1">
                                    <TextBlock Text="{Binding Path=ShortName, Mode=OneWay}" TextTrimming="CharacterEllipsis"/>
                                    <TextBlock Text="{Binding Path=FileName, Mode=OneWay}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Path=FileName, Mode=OneWay}"/>
                                </StackPanel>

                                <Button Width="18" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" 
                                                BorderBrush="Transparent" BorderThickness="0" Background="Transparent" Padding="0"
                                                Command="{Binding Path=DataContext.MoveToTopCommand, ElementName=lstBoxMRUEntries}"
                                                CommandParameter="{Binding Path=MRUFileEntry}">
                                    <Image Source="/Tum.PDE.ToolFramework.Images;component/Ribbon/Up-16.png"/>
                                </Button>
                                <Button Width="18" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" 
                                                BorderBrush="Transparent" BorderThickness="0" Background="Transparent" Padding="0"
                                                Command="{Binding Path=DataContext.RemoveCommand, ElementName=lstBoxMRUEntries}"
                                                CommandParameter="{Binding Path=MRUFileEntry}">
                                    <Image Source="/Tum.PDE.ToolFramework.Images;component/Ribbon/Delete-16.png"/>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>

                    <ListBox.ItemContainerStyle>
                        <Style TargetType="{x:Type ListBoxItem}">
                            <Setter Property="attached:CommandBehavior.Event" Value="MouseDoubleClick" />
                            <Setter Property="attached:CommandBehavior.Command" Value="{Binding ElementName=lstBoxMRUEntries, Path=DataContext.OpenCommand}" />
                            <Setter Property="attached:CommandBehavior.CommandParameter" Value="{Binding ElementName=lstBoxMRUEntries, Path=DataContext.SelectedMRUFileEntry.MRUFileEntry}" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                        <Grid Background="#00000000" Margin="0,3">
                                            <Border x:Name="border" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1" Margin="0" CornerRadius="3" Background="{DynamicResource TransparentBrush}">
                                                <Border x:Name="border1" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}">
                                                    <ContentPresenter Margin="5,5,15,5"/>
                                                </Border>
                                            </Border>
                                            <Path x:Name="path" Data="M1,0L0,1 1,2" Fill="#FFF4F4F5" HorizontalAlignment="Right" Height="11" Margin="0,0,-0.4,0" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" Stroke="{DynamicResource RibbonTopBorderBrush}" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" VerticalAlignment="Center" Width="6" Visibility="Collapsed"/>
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="Selector.IsSelected" Value="True">
                                                <Setter Property="Visibility" TargetName="path" Value="Visible"/>
                                                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonPressedOuterBackgroundBrush}"/>
                                                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
                                                <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBorderBrush}"/>
                                                <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
                                            </Trigger>
                                            <MultiTrigger>
                                                <MultiTrigger.Conditions>
                                                    <Condition Property="IsMouseOver" Value="True"/>
                                                    <Condition Property="Selector.IsSelected" Value="False"/>
                                                </MultiTrigger.Conditions>
                                                <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                                                <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
                                                <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
                                                <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                                            </MultiTrigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </StackPanel>
        </ScrollViewer>
    </ControlTemplate>

    <ControlTemplate x:Key="RibbonBackstageFurtherInformationTemplate">
        <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
            <StackPanel Margin="15, 10, 0, 0" Orientation="Vertical" Width="500" HorizontalAlignment="Left">
                <!-- Further Information TextBlock -->
                <Grid Margin="0,0,10,0">
                    <TextBlock Margin="0,5" TextWrapping="Wrap" Text="Further Information" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Foreground="#FF5E5E5E"/>
                    <Path Data="M0,0L1,0" Fill="{x:Null}" Height="1" Margin="0" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" Stroke="{DynamicResource RibbonTopBorderBrush}" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" VerticalAlignment="Bottom" StrokeDashArray="2 2"/>
                </Grid>

                <!-- Uncategorized items -->
                <ListBox Width="500" Margin="0, 10, 0, 0" BorderThickness="0" BorderBrush="Transparent"
                                            ItemsSource="{Binding Path=FurtherReadingViewModel.LinkItemVMsWithoutCategory, Mode=OneWay}"
                                            ItemTemplate="{StaticResource LinkItemUncategorizedTemplate}"
                                            ItemContainerStyle="{StaticResource BackstageListBoxItemNoSelection}"
                                            Visibility="{Binding Path=FurtherReadingViewModel.HasLinkItemVMsWithoutCategory, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
                </ListBox>

                <!-- Categorized items -->
                <ItemsControl Width="500" Margin="0, 10, 0, 0" BorderThickness="0" BorderBrush="Transparent" Focusable="False"
                                            ItemsSource="{Binding Path=FurtherReadingViewModel.LinkItemVmsCategorized, Mode=OneWay}"
                                            ItemTemplate="{StaticResource LinkItemsCategorizedTemplate}"
                                            Visibility="{Binding Path=FurtherReadingViewModel.HasLinkItemVmsCategorized, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
                </ItemsControl>
            </StackPanel>
        </ScrollViewer>
    </ControlTemplate>

    <ControlTemplate x:Key="RibbonBackstageCreditsTemplate">
        <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
            <StackPanel Margin="15, 10, 0, 0" Orientation="Vertical" Width="500" HorizontalAlignment="Left">
                <!-- Credits Information TextBlock -->
                <Grid Margin="0,0,10,0">
                    <TextBlock Margin="0,5" TextWrapping="Wrap" Text="Credits" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Foreground="#FF5E5E5E"/>
                    <Path Data="M0,0L1,0" Fill="{x:Null}" Height="1" Margin="0" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" Stroke="{DynamicResource RibbonTopBorderBrush}" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" VerticalAlignment="Bottom" StrokeDashArray="2 2"/>
                </Grid>

                <!-- Uncategorized items -->
                <ListBox Width="500" Margin="0, 10, 0, 0" BorderThickness="0" BorderBrush="Transparent"
                                            ItemsSource="{Binding Path=CreditsViewModel.LinkItemVMsWithoutCategory, Mode=OneWay}"
                                            ItemTemplate="{StaticResource LinkItemUncategorizedTemplate}"
                                            ItemContainerStyle="{StaticResource BackstageListBoxItemNoSelection}"
                                            Visibility="{Binding Path=CreditsViewModel.HasLinkItemVMsWithoutCategory, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
                </ListBox>

                <!-- Categorized items -->
                <ItemsControl Width="500" Margin="0, 10, 0, 0" BorderThickness="0" BorderBrush="Transparent" Focusable="False"
                                            ItemsSource="{Binding Path=CreditsViewModel.LinkItemVmsCategorized, Mode=OneWay}"
                                            ItemTemplate="{StaticResource LinkItemsCategorizedTemplate}"
                                            Visibility="{Binding Path=CreditsViewModel.HasLinkItemVmsCategorized, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
                </ItemsControl>
            </StackPanel>
        </ScrollViewer>
    </ControlTemplate>


    <ControlTemplate x:Key="RibbonViewTabMCTemplate">
        <fluent:InRibbonGallery ItemWidth="150" ItemHeight="24" ResizeMode="Both"
                                      MinItemsInRow="2" MaxItemsInRow="3" 
                                      ItemsSource="{Binding Path=AvailableModelModelContextViewModels, Mode=OneWay}"
                                      Focusable="False" MinWidth="150" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch">
            <fluent:InRibbonGallery.ItemTemplate>
                <DataTemplate>
                    <Button Command="{Binding Path=SelectModelContextCommand}" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Focusable="False">
                        <TextBlock Margin="3,0,0,0" Text="{Binding Path=Titel, Mode=OneTime}" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                   ToolTip="{Binding Path=DockingPaneTitle, Mode=OneTime}"/>
                    </Button>
                </DataTemplate>
            </fluent:InRibbonGallery.ItemTemplate>
            <fluent:InRibbonGallery.ItemContainerStyle>
                <Style TargetType="{x:Type fluent:GalleryItem}" BasedOn="{StaticResource GalleryItemStyle}">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=OneWay}"/>
                </Style>
            </fluent:InRibbonGallery.ItemContainerStyle>
        </fluent:InRibbonGallery>
    </ControlTemplate>
    <ControlTemplate x:Key="RibbonViewTabAVTemplate">
        <fluent:InRibbonGallery ItemWidth="200" ItemHeight="24" ResizeMode="Both" 
                                      MinItemsInRow="2" MaxItemsInRow="3"  Selectable="False"
                                      ItemsSource="{Binding Path=SelectedModelContextViewModel.AdditionalDiagramSurfaceModels, Mode=OneWay}"
                                      Focusable="False" MinWidth="150" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch">
            <fluent:InRibbonGallery.ItemTemplate>
                <DataTemplate>
                    <ribbonHelper:RibbonInGalleryItem IsSelectedItem="{Binding Path=IsDockingPaneVisible, Mode=OneWay}">
                        <Button Command="{Binding Path=ShowDockingPaneCommand}" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Focusable="False">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Margin="3,0,0,0" Text="{Binding Path=DockingPaneTitle, Mode=OneWay}" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   ToolTip="{Binding Path=DockingPaneTitle, Mode=OneWay}"/>
                            </StackPanel>
                        </Button>
                    </ribbonHelper:RibbonInGalleryItem>
                </DataTemplate>
            </fluent:InRibbonGallery.ItemTemplate>
        </fluent:InRibbonGallery>
    </ControlTemplate>

    <ControlTemplate x:Key="RibbonPluginsTabFPTemplate">
        <ListBox ItemsSource="{Binding Path=SelectedModelContextViewModel.Plugins, Mode=OneWay}" x:Name="pluginsList"
                             Background="Transparent" BorderThickness="0" BorderBrush="Transparent"
                             ScrollViewer.VerticalScrollBarVisibility="Disabled"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <fluent:Button MinWidth="32" Text="{Binding Path=MenuName, Mode=OneWay}" LargeIcon="{Binding Path=MenuImage, Mode=OneTime}" SizeDefinition="Large"
                                               Command="{Binding Path=DataContext.SelectedModelContextViewModel.ExecutePluginCommand, ElementName=pluginsList}" 
                                               CommandParameter="{Binding}"
                                               ToolTip="{Binding Path=MenuName, Mode=OneTime}">
                    </fluent:Button>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>

    </ControlTemplate>
    <ControlTemplate x:Key="RibbonPluginsTabVPTemplate">
        <fluent:InRibbonGallery ItemWidth="200" ItemHeight="24" ResizeMode="Both"
                                      MinItemsInRow="2" MaxItemsInRow="3" Selectable="False"
                                      ItemsSource="{Binding Path=SelectedModelContextViewModel.PluginDiagramSurfaceModels, Mode=OneWay}"
                                      Focusable="False" MinWidth="150" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch">
            <fluent:InRibbonGallery.ItemTemplate>
                <DataTemplate>
                    <ribbonHelper:RibbonInGalleryItem IsSelectedItem="{Binding Path=IsDockingPaneVisible, Mode=OneWay}">
                        <Button Command="{Binding Path=ShowDockingPaneCommand}" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Focusable="False">
                            <TextBlock Margin="3,0,0,0" Text="{Binding Path=DockingPaneTitle, Mode=OneWay}" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   ToolTip="{Binding Path=DockingPaneTitle, Mode=OneWay}"/>
                        </Button>
                    </ribbonHelper:RibbonInGalleryItem>
                </DataTemplate>
            </fluent:InRibbonGallery.ItemTemplate>
        </fluent:InRibbonGallery>
    </ControlTemplate>
</ResourceDictionary>